<?php

class Country_Widget_ProfileHeaderController extends Engine_Content_Widget_Abstract
{
  public function indexAction()
  {
	     // Don't render this if not authorized
    $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
    if( !Engine_Api::_()->core()->hasSubject() ) {
      return $this->setNoRender();
    }

    // Get subject and check auth
    $this->view->subject = $subject = Engine_Api::_()->core()->getSubject('country');	

     $request = Zend_Controller_Front::getInstance()->getRequest();
     $this->getElement()->removeDecorator('title');
     $id = $request->getParam('id');
     $this->view->error = false;
     $this->view->id = $id;
	 
     $request = Zend_Controller_Front::getInstance()->getRequest();
        
        $structure = array (
				'type' => 'widget', 
				'name' => 'country.field-profile', 
				'request' => $request, 
				'action' => 'index'
			);
			
			// Create element (with structure)
			$element = new Engine_Content_Element_Container(array (
				'elements' => array (
					$structure
				), 
				'decorators' => array (
					'Children'
				)
			));
        $profile_field =  $element->render();
        $this->view->profile_field = $profile_field;
  }
}
